#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QPainter>
#include  <QPixmap>
#include <QMouseEvent>
#include "sktsetstyle.h"
#include <QDebug>
#include <QAction>
#include <QTreeWidgetItem>
#include <QLabel>


#include "opencv2/opencv.hpp"

#include "capturethread.h"



QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow,public SktSetStyle
{
    Q_OBJECT

public:
    virtual void paintEvent(QPaintEvent *);
    virtual void mousePressEvent(QMouseEvent *event);
    virtual void mouseMoveEvent(QMouseEvent* event);
    virtual bool eventFilter(QObject *watched, QEvent *event);
    virtual void  keyPressEvent(QKeyEvent *event);


//    virtual void resizeEvent(QResizeEvent *event) override;


 public slots:
    void SktCloseBtnSlots();
    void SktMaxBtnSlots();
    void SktMinBtnSlots();

    void SktIndexBtnSlots();
    void SktVideoBtnSlots();
    void SktCmaTreeWdtSlot(QTreeWidgetItem *pSubTree,int k);

    void SktFullScreenSlots();//全屏

    void SktPTZLeftSlots();//left button
    void SktPTZRightSlots();//right
    void SktPTZUpSlots();//up
    void SktPTZDownSlots();//download


public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

    //初始化界面
    void  SktInitCmaSys();
    //信号与槽函数关联
    void SktSetSignal();

    //加入摄像头
    void SktAddCmaList();

     void ptzControlRealPlay(int command,int flag);



private:
    void SktAddSubItem(QTreeWidgetItem *pRootItem,const char *pstIp,const char *pstPicPath);

    void SktInitAllLbl();
    void  SktSetCurLblMax();
    bool m_bIsMax=false;//当前通道是否最大化
    void SktShowHideOtherWdt(bool isShow);

     void openCamera();
     void updateFrame(cv::Mat *mat);
     void setLablWH();//保存labl的宽高
      bool linkHik();//测试，联接海康


      //void CALLBACK  ExceptionCallBack(DWORD dwType, LONG lUserID, LONG lHandle, void *pUser);



private:
    Ui::MainWindow *ui;

private:
    QLabel *m_pQLabel[16];
    QLabel *m_pCurLbl;


    cv::Mat currentFrame;

    // for capture thread
    QMutex *data_lock;
    CaptureThread *capturer;


private:
    QPixmap m_oQPixmap;
    QPixmap m_oPixmap2;
    QPoint m_oQPoint;
    cv::Size m_oLblWH[16];//16个lable的宽高

    cv::Size m_oCurrentLblSize;

    int cameraHandler[1024];//1024个最大的摄像头


    //测试用
    cv::Mat gray,edge;
    int curCamHandler=0;


    //PTZ module
        int m_rpptzspeed;
        int m_ptzupswitch;
        int m_ptzdownswitch;
        int m_ptzrghtswitch;
        int m_ptzleftswitch;
        int m_ptznarrowswitch;
        int m_ptzexpandswitch;
        int m_ptzfarswitch;
        int m_ptznearswitch;
        int m_ptzbigswitch;
        int m_ptzsmallswitch;



};
#endif // MAINWINDOW_H
